package com.dlwx.parttimetalent.adapter;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.widget.TextView;

import com.dlwx.parttimetalent.R;
import com.dlwx.parttimetalent.bean.ConfirmOrderBean;
import com.github.jdsjlzx.ItemDecoration.GridItemDecoration;
import com.github.jdsjlzx.recyclerview.LRecyclerView;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;

import java.util.List;

/**
 * Created by Administrator on 2017/11/21.
 */

public class NoTimeAdapter extends ListBaseAdapter<ConfirmOrderBean.BodyBean.BkyyBean> {
    private  Context context;
    public NoTimeAdapter(Context context) {
        super(context);
        this.context=context;
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_no_time;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        ConfirmOrderBean.BodyBean.BkyyBean bean = getDataList().get(position);
        TextView tv_date = holder.getView(R.id.tv_date);
        tv_date.setText(bean.getDate());
        LRecyclerView recyclerView = holder.getView(R.id.recyclerView);
        List<ConfirmOrderBean.BodyBean.BkyyBean.TimeListBean> timeList = bean.getTimelist();
        if(!timeList.isEmpty()){
            initDatas(recyclerView,timeList);
        }
    }

    private void initDatas(LRecyclerView recyclerView, List<ConfirmOrderBean.BodyBean.BkyyBean.TimeListBean> timeList) {
        GridLayoutManager manager = new GridLayoutManager(context, 3);
        manager.setAutoMeasureEnabled(true);
        recyclerView.setLayoutManager(manager);
        NoTimeChildAdapter mAdapter = new NoTimeChildAdapter(context);
        mAdapter.setDataList(timeList);
        LRecyclerViewAdapter lRecyclerViewAdapter=new LRecyclerViewAdapter(mAdapter);
        //divider
        GridItemDecoration divider = new GridItemDecoration.Builder(context)
//                .setHorizontal(R.dimen.size_4)
                .setVertical(R.dimen.size_20)
                .setColorResource(R.color.white)
                .build();
//        recyclerView.addItemDecoration(divider);
        recyclerView.setAdapter(lRecyclerViewAdapter);
        recyclerView.setPullRefreshEnabled(false);
        recyclerView.setLoadMoreEnabled(false);
    }
}
